from  utils import *


client="mongodb://172.23.130.245:27017/"
collect_name="hugging_face"
db='datasets'

# client = pymongo.MongoClient(client)
# db = client[db]
# collect = db[collect_name]
# collect.aggregate([
#   { '$match': { 'view': { '$exists': True } } },
#   { '$out': "hugging_face" }
# ])

dataset = mongo_manager(collect_name=collect_name, client=client, db=db)
# aa=dataset.updateMany({}, {"num":"size.Number of rows:"})
all_data=dataset.findAll()
for i in all_data:
  try:
    print(num:=int(i.get("size")["Number of rows:"].replace(',', '')))
    dataset.find_one_and_update({"_id":i['_id']},{"num":num})
  except BaseException as e:
    print(e)
    print(i.get("size"))

dataset.close()